
* P�rez-Li��n, An�bal, and Scott Mainwaring (2013) 
* "Regime Legacies and Levels of Democracy: Evidence from Latin America." 
* Comparative Politics 45 (4):379-397
* Replication file: Nov 17 2011

* use dataset regime_legacies.dat

xtset cc_cow year

* Create country-average and de-meaned (group-centered) variables for Allison estimator

egen mghist10=mean(ghist10), by(cc_cow)
label var mghist10 "Growth, 10 years"
gen  dghist10=ghist10-mghist10
label var dghist10 "Growth, 10 years"
egen mihist10=mean(ihist10), by(cc_cow)
label var mihist10 "Inflation, 10 years"
gen  dihist10=ihist10-mihist10
label var dihist10 "Inflation, 10 years"
egen mlfi =mean(lfi), by(cc_cow)
label var mlfi "Labor force in industry"
gen  dlfi = lfi-mlfi
label var dlfi "Labor force in industry"
egen mdif04a =mean(dif04a), by(cc_cow)
label var mdif04a "Democracy neighbors"
gen  ddif04a = dif04a-mdif04a
label var ddif04a "Democracy neighbors"
egen mmultip =mean(multip), by(cc_cow)
label var mmultip "Multipartism"
gen  dmultip = multip-mmultip
label var dmultip "Multipartism"
egen mlog_pgdp =mean(log_pgdp), by(cc_cow)
label var mlog_pgdp "Per capita GDP, ln"
gen  dlog_pgdp = log_pgdp-mlog_pgdp
label var dlog_pgdp "Per capita GDP, ln"
egen mwfimp =mean(wfimp), by(cc_cow)
label var mwfimp "Fuel and mineral exports"
gen  dwfimp = wfimp-mwfimp
label var dwfimp "Fuel and mineral exports"
egen mdi_h =mean(di_h), by(cc_cow)
label var mdi_h "Party institutionalization"
gen  ddi_h = di_h-mdi_h
label var ddi_h "Party institutionalization"
egen mdi_sc =mean(di_sc), by(cc_cow)
label var mdi_sc "Court institutionalization"
gen  ddi_sc = di_sc-mdi_sc
label var ddi_sc "Court institutionalization"
egen mgini =mean(gini_), by(cc_cow)
label var mgini "Gini index"
gen  dgini = (gini_)-mgini
label var dgini "Gini index"


* Table 2

* 2.1 Conventional fixed-effects model (using original variables) 
xi: xtreg  fh   ghist10   ihist10  lfi  dif04a  multip  log_pgdp  wfimp i.year, fe

* 2.2 Polity
gen democ=d_00_77_p
label var democ "Democracy (1900-77)"
xi: xtmixed fh  dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ i.year || cc_cow: , reml 

**    Consistency check: Model 2.2 with Gini index
xi: xtmixed fh  dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp dgini  ///             
            mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp mgini ///
            soc10 democ i.year || cc_cow: , reml

* 2.3 Mainwaring et al
replace democ=d_00_77	
xi: xtmixed fh  dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ i.year || cc_cow: , reml 

* 2.4 Smith
replace democ=d_00_77_s
xi: xtmixed fh  dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ i.year || cc_cow: , reml

	 
* Table 4

* 4.1 Conventional fixed-effects model (using original variables)
xi: xtreg  fh   di_h di_sc ghist10  ihist10  lfi  dif04a  multip  log_pgdp  wfimp i.year, fe

* 4.2 Polity
replace democ=d_00_77_p
xi: xtmixed fh  ddi_h ddi_sc dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mdi_h mdi_sc mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ lb_sd2 elites_d i.year || cc_cow: , reml

* 4.3 Mainwaring et al
xi: xtmixed fh  ddi_h ddi_sc dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mdi_h mdi_sc mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ lb_sd2 elites_d i.year || cc_cow: , reml

* 4.4 Smith
replace democ=d_00_77_s
xi: xtmixed fh  ddi_h ddi_sc dghist10 dihist10 dlfi ddif04a dmultip dlog_pgdp dwfimp  ///             
            mdi_h mdi_sc mghist10 mihist10 mlfi mdif04a mmultip mlog_pgdp mwfimp  ///
            soc10 democ lb_sd2 elites_d i.year || cc_cow: , reml


* Consistency checks (using Polity)

* Baseline random-effects model

xi: xtmixed fh di_h di_sc ghist10 ihist10 lfi dif04a multip log_pgdp wfimp d_00_77_p soc10 lb_sd2 elites_d i.year ///
  || cc_cow:  , reml

* PT Estimator

xi: xtfevd fh di_h di_sc ghist10 ihist10 lfi dif04a multip log_pgdp wfimp i.year d_00_77_p soc10 lb_sd2 elites_d, ///
      invariant(d_00_77_p soc10 lb_sd2 elites_d)
	  
xi: xtfevd fh di_h di_sc ghist10 ihist10 lfi dif04a multip log_pgdp wfimp i.year d_00_77 soc10 lb_sd2 elites_d, ///
      invariant(d_00_77 soc10 lb_sd2 elites_d)

xi: xtfevd fh di_h di_sc ghist10 ihist10 lfi dif04a multip log_pgdp wfimp i.year d_00_77_s soc10 lb_sd2 elites_d, ///
      invariant(d_00_77_s soc10 lb_sd2 elites_d)	  
	  
drop democ
